package com.qf.quduba.service.impl;

import com.qf.quduba.dao.CommentDao;
import com.qf.quduba.entity.Comment;
import com.qf.quduba.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 作者：程意
 * 时间：2020/10/16 10:57
 */
@Service
public class CommentServiceImpl implements CommentService {
    @Resource
    private CommentDao commentDao;
    Comment comment = new Comment();
    @Override
    public List<Comment> findCommentByBookId(String bookId) {
        return commentDao.findCommentByBookId(bookId);
    }

    @Override
    public int saveComment(String commentDetail,String bookId,String userId) {
        comment.setCommentTime(new Date());
        comment.setBookId(Integer.parseInt(bookId));
        comment.setUserId(Integer.parseInt(userId));
        comment.setCommentDetail(commentDetail);
        return commentDao.saveComment(comment);
    }

    @Override
    public int deleteComment(String commentId) {
        return commentDao.deleteComment(Integer.parseInt(commentId));
    }

    @Override
    public int updateCommentNum(String commentId) {
        return commentDao.updateCommentNum(Integer.parseInt(commentId));
    }

    @Override
    public Comment findCommentOne(Integer commentId) {
        return commentDao.findCommentOne(commentId);
    }

    @Override
    public List<Comment> findByBookId(Integer bookId) {
        return commentDao.findByBookId(bookId);
    }
}
